package com.huangwei.controller;

import com.huangwei.model.UserAddress;
import com.huangwei.service.UserAddressService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("userAddress")
public class UserAddressController {
    @Resource
    UserAddressService userAddressService;

    @GetMapping("getAddress")
    public List<UserAddress> getAddress(HttpServletRequest request) {
        Map<String, String[]> map = request.getParameterMap();
        return userAddressService.getAddressByUser(Integer.parseInt(map.get("user")[0]));
    }
}
